package acwing;

import java.io.*;
import java.util.*;

public class ac796 {
    static final int N = 1010;
    static int[][] a = new int[N][N];
    static int[][] s = new int[N][N];
    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s1 = in.readLine().split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        int q = Integer.parseInt(s1[2]);
        for(int i = 1; i <= n; i ++ ){
            String[] matrix = in.readLine().split(" ");
            for(int j = 1; j <= m; j ++ ){
                a[i][j] = Integer.parseInt(matrix[j - 1]);
                s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + a[i][j];
            }
        }
        while(q -- > 0){
            String[] x = in.readLine().split(" ");
            int x1 = Integer.parseInt(x[0]);
            int y1 = Integer.parseInt(x[1]);
            int x2 = Integer.parseInt(x[2]);
            int y2 = Integer.parseInt(x[3]);
            int res = s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
            System.out.println(res);
        }
    }
}
